Skip to contentSkip to conversation

Change in openvpn[master]: CMake: fix broken daemonization and syslog functionality

Openvpn-devel In review stipa (Code Review) 3 participants 8 messages Sep 15, 2023 – Sep 20, 2023 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1694783050000.I171d55da2be868d961caa1d4491e6f1ed10ebe8a@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/341?usp=email

to review the following change.

Change subject: CMake: fix broken daemonization and syslog functionality
......................................................................

CMake: fix broken daemonization and syslog functionality

While CMake is not the official way to build OpenVPN on Linux, it still make sense to support it. Turns out that

HAVE_SETSID, HAVE_OPENLOG and HAVE_SYSLOG

were not set by CMake configure, and --daemon and syslog functionality was broken.

While on it, fix compiler error on unused return value of chdir().

Change-Id I171d55da2be868d961caa1d4491e6f1ed10ebe8a

---
M CMakeLists.txt
M config.h.cmake.in
M src/compat/compat-daemon.c

3 files changed, 8 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/341/1

CMakeLists.txt +1 -0
index 7dae665..9de6aba 100644
@@ -150,6 +150,7 @@
 check_symbol_exists(ftruncate unistd.h HAVE_FTRUNCATE)
 check_symbol_exists(setgid unistd.h HAVE_SETGID)
 check_symbol_exists(setuid unistd.h HAVE_SETUID)
+check_symbol_exists(setsid unistd.h HAVE_SETSID)
 check_symbol_exists(getpeereid unistd.h HAVE_GETPEEREID)
 
 check_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL_CREATE)
config.h.cmake.in +3 -3
index 4f28917..f2cdd39 100644
@@ -218,7 +218,7 @@
 #undef HAVE_NICE
 
 /* Define to 1 if you have the `openlog' function. */
-#undef HAVE_OPENLOG
+#cmakedefine HAVE_OPENLOG
 
 /* OpenSSL engine support available */
 #undef HAVE_OPENSSL_ENGINE
@@ -258,7 +258,7 @@
 #undef HAVE_SETGROUPS
 
 /* Define to 1 if you have the `setsid' function. */
-#undef HAVE_SETSID
+#cmakedefine HAVE_SETSID
 
 /* Define to 1 if you have the `setsockopt' function. */
 #define HAVE_SETSOCKOPT 1
@@ -303,7 +303,7 @@
 #undef HAVE_STRSEP
 
 /* Define to 1 if you have the `syslog' function. */
-#undef HAVE_SYSLOG
+#cmakedefine HAVE_SYSLOG
 
 /* Define to 1 if you have the <syslog.h> header file. */
 #cmakedefine HAVE_SYSLOG_H
src/compat/compat-daemon.c +4 -1
index aebb8f4..5c6d740 100644
@@ -70,7 +70,10 @@
 
     if (!nochdir)
     {
-        chdir("/");
+        if (chdir("/") == -1)
+        {
+            return (-1);
+        }
     }
 
     if (!noclose)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/341?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I171d55da2be868d961caa1d4491e6f1ed10ebe8a
Gerrit-Change-Number: 341
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

author Acked-by Frank Lichtenheld
#2 lore raw
In reply to a message not in the archive

Attention is currently required from: stipa.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/341?usp=email )

Change subject: CMake: fix broken daemonization and syslog functionality
......................................................................

Patch Set 1: Code-Review+2

(1 comment)

Patchset:

PS1:

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/341?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I171d55da2be868d961caa1d4491e6f1ed10ebe8a
Gerrit-Change-Number: 341
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 15 Sep 2023 13:08:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: stipa.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/341?usp=email )

Change subject: CMake: fix broken daemonization and syslog functionality
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/341?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I171d55da2be868d961caa1d4491e6f1ed10ebe8a
Gerrit-Change-Number: 341
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 15 Sep 2023 13:18:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#4 lore raw

PATCH 1/1 CMake: fix broken daemonization and syslog functionality

In reply to a message not in the archive

From: Lev Stipakov <[email protected]...>

While CMake is not the official way to build OpenVPN on Linux, it still make sense to support it. Turns out that

HAVE_SETSID, HAVE_OPENLOG and HAVE_SYSLOG

were not set by CMake configure, and --daemon and syslog functionality was broken.

While on it, fix compiler error on unused return value of chdir().

Change-Id I171d55da2be868d961caa1d4491e6f1ed10ebe8a

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/341
This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
Frank Lichtenheld <[email protected]...>

CMakeLists.txt +1 -0
index 7dae665..9de6aba 100644
@@ -150,6 +150,7 @@
 check_symbol_exists(ftruncate unistd.h HAVE_FTRUNCATE)
 check_symbol_exists(setgid unistd.h HAVE_SETGID)
 check_symbol_exists(setuid unistd.h HAVE_SETUID)
+check_symbol_exists(setsid unistd.h HAVE_SETSID)
 check_symbol_exists(getpeereid unistd.h HAVE_GETPEEREID)
 
 check_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL_CREATE)
config.h.cmake.in +3 -3
index 4f28917..f2cdd39 100644
@@ -218,7 +218,7 @@
 #undef HAVE_NICE
 
 /* Define to 1 if you have the `openlog' function. */
-#undef HAVE_OPENLOG
+#cmakedefine HAVE_OPENLOG
 
 /* OpenSSL engine support available */
 #undef HAVE_OPENSSL_ENGINE
@@ -258,7 +258,7 @@
 #undef HAVE_SETGROUPS
 
 /* Define to 1 if you have the `setsid' function. */
-#undef HAVE_SETSID
+#cmakedefine HAVE_SETSID
 
 /* Define to 1 if you have the `setsockopt' function. */
 #define HAVE_SETSOCKOPT 1
@@ -303,7 +303,7 @@
 #undef HAVE_STRSEP
 
 /* Define to 1 if you have the `syslog' function. */
-#undef HAVE_SYSLOG
+#cmakedefine HAVE_SYSLOG
 
 /* Define to 1 if you have the <syslog.h> header file. */
 #cmakedefine HAVE_SYSLOG_H
src/compat/compat-daemon.c +4 -1
index aebb8f4..5c6d740 100644
@@ -70,7 +70,10 @@
 
     if (!nochdir)
     {
-        chdir("/");
+        if (chdir("/") == -1)
+        {
+            return (-1);
+        }
     }
 
     if (!noclose)
#5 lore raw

Re: [Openvpn-devel] [PATCH] CMake: fix broken daemonization and syslog functionality

Quoted 18 lines · Frank Lichtenheld

From: Lev Stipakov <[email protected]...>

While CMake is not the official way to build OpenVPN on Linux, it still make sense to support it. Turns out that

HAVE_SETSID, HAVE_OPENLOG and HAVE_SYSLOG

were not set by CMake configure, and --daemon and syslog functionality was broken.

While on it, fix compiler error on unused return value of chdir().

Change-Id I171d55da2be868d961caa1d4491e6f1ed10ebe8a

---

Quoted 8 lines

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/341
This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
Frank Lichtenheld <[email protected]...>

So I can automatically set In-Reply-To to the same "virtual" message ID that Gerrit uses (since that is deterministally constructed from the change metadata). However, since this is not the actual message ID by the original "newchange" mail, it still doesn't associate to the same "Patch" in Patchwork. Instead it creates a new patch.

Regards,

Signature · 1 line
  Frank Lichtenheld
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: CMake: fix broken daemonization and syslog functionality

In reply to Frank Lichtenheld

Your patch has been applied to the master branch.

I have not tested it further, given that it has plenty of ACKs (and only affects cmake build system).

Two observations, though - the cmake changes look incomplete, there is still many "#undef HAVE_something" left. Shouldn't they all be completed to "#cmakedefine" for this to make sense?

Second, while not really relevant on Linux or *BSD, erroring-out in daemon() on chdir("/") fail is not what either manpage documents - and I do not think chdir("/") (as root) can ever fail. So changing the code flow just to silence the compiler feels a bit meh - doing a (void) there would have silenced it just fine. But as I said it's not truly relevant.

What OS were you building anyway that you hit an error in compat-daemon.c (aka "are we missing a cmake test for daemon()")?

commit 8ae6c48d5d52dec8ec6e47cc1cfe89de9f2ffbcd (master)

Author: Lev Stipakov
Date:   Wed Sep 20 14:15:19 2023 +0200
     CMake: fix broken daemonization and syslog functionality

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg27045.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#7 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/341?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld, Code-Review+2 by plaisthos

Change subject: CMake: fix broken daemonization and syslog functionality
......................................................................

CMake: fix broken daemonization and syslog functionality

While CMake is not the official way to build OpenVPN on Linux, it still make sense to support it. Turns out that

HAVE_SETSID, HAVE_OPENLOG and HAVE_SYSLOG

were not set by CMake configure, and --daemon and syslog functionality was broken.

While on it, fix compiler error on unused return value of chdir().

Change-Id I171d55da2be868d961caa1d4491e6f1ed10ebe8a

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27045.html

---
M CMakeLists.txt
M config.h.cmake.in
M src/compat/compat-daemon.c

3 files changed, 8 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/341/2

CMakeLists.txt +1 -0
index 7dae665..9de6aba 100644
@@ -150,6 +150,7 @@
 check_symbol_exists(ftruncate unistd.h HAVE_FTRUNCATE)
 check_symbol_exists(setgid unistd.h HAVE_SETGID)
 check_symbol_exists(setuid unistd.h HAVE_SETUID)
+check_symbol_exists(setsid unistd.h HAVE_SETSID)
 check_symbol_exists(getpeereid unistd.h HAVE_GETPEEREID)
 
 check_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL_CREATE)
config.h.cmake.in +3 -3
index 4f28917..f2cdd39 100644
@@ -218,7 +218,7 @@
 #undef HAVE_NICE
 
 /* Define to 1 if you have the `openlog' function. */
-#undef HAVE_OPENLOG
+#cmakedefine HAVE_OPENLOG
 
 /* OpenSSL engine support available */
 #undef HAVE_OPENSSL_ENGINE
@@ -258,7 +258,7 @@
 #undef HAVE_SETGROUPS
 
 /* Define to 1 if you have the `setsid' function. */
-#undef HAVE_SETSID
+#cmakedefine HAVE_SETSID
 
 /* Define to 1 if you have the `setsockopt' function. */
 #define HAVE_SETSOCKOPT 1
@@ -303,7 +303,7 @@
 #undef HAVE_STRSEP
 
 /* Define to 1 if you have the `syslog' function. */
-#undef HAVE_SYSLOG
+#cmakedefine HAVE_SYSLOG
 
 /* Define to 1 if you have the <syslog.h> header file. */
 #cmakedefine HAVE_SYSLOG_H
src/compat/compat-daemon.c +4 -1
index aebb8f4..5c6d740 100644
@@ -70,7 +70,10 @@
 
     if (!nochdir)
     {
-        chdir("/");
+        if (chdir("/") == -1)
+        {
+            return (-1);
+        }
     }
 
     if (!noclose)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/341?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I171d55da2be868d961caa1d4491e6f1ed10ebe8a
Gerrit-Change-Number: 341
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#8 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/341?usp=email )

Change subject: CMake: fix broken daemonization and syslog functionality
......................................................................

CMake: fix broken daemonization and syslog functionality

While CMake is not the official way to build OpenVPN on Linux, it still make sense to support it. Turns out that

HAVE_SETSID, HAVE_OPENLOG and HAVE_SYSLOG

were not set by CMake configure, and --daemon and syslog functionality was broken.

While on it, fix compiler error on unused return value of chdir().

Change-Id I171d55da2be868d961caa1d4491e6f1ed10ebe8a

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27045.html

---
M CMakeLists.txt
M config.h.cmake.in
M src/compat/compat-daemon.c

3 files changed, 8 insertions(+), 4 deletions(-)
CMakeLists.txt +1 -0
index 7dae665..9de6aba 100644
@@ -150,6 +150,7 @@
 check_symbol_exists(ftruncate unistd.h HAVE_FTRUNCATE)
 check_symbol_exists(setgid unistd.h HAVE_SETGID)
 check_symbol_exists(setuid unistd.h HAVE_SETUID)
+check_symbol_exists(setsid unistd.h HAVE_SETSID)
 check_symbol_exists(getpeereid unistd.h HAVE_GETPEEREID)
 
 check_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL_CREATE)
config.h.cmake.in +3 -3
index 4f28917..f2cdd39 100644
@@ -218,7 +218,7 @@
 #undef HAVE_NICE
 
 /* Define to 1 if you have the `openlog' function. */
-#undef HAVE_OPENLOG
+#cmakedefine HAVE_OPENLOG
 
 /* OpenSSL engine support available */
 #undef HAVE_OPENSSL_ENGINE
@@ -258,7 +258,7 @@
 #undef HAVE_SETGROUPS
 
 /* Define to 1 if you have the `setsid' function. */
-#undef HAVE_SETSID
+#cmakedefine HAVE_SETSID
 
 /* Define to 1 if you have the `setsockopt' function. */
 #define HAVE_SETSOCKOPT 1
@@ -303,7 +303,7 @@
 #undef HAVE_STRSEP
 
 /* Define to 1 if you have the `syslog' function. */
-#undef HAVE_SYSLOG
+#cmakedefine HAVE_SYSLOG
 
 /* Define to 1 if you have the <syslog.h> header file. */
 #cmakedefine HAVE_SYSLOG_H
src/compat/compat-daemon.c +4 -1
index aebb8f4..5c6d740 100644
@@ -70,7 +70,10 @@
 
     if (!nochdir)
     {
-        chdir("/");
+        if (chdir("/") == -1)
+        {
+            return (-1);
+        }
     }
 
     if (!noclose)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/341?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I171d55da2be868d961caa1d4491e6f1ed10ebe8a
Gerrit-Change-Number: 341
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged